import Page
from Page import App
from Base.Base import Base
from selenium.webdriver.common.by import By


class AppDetailPage(Base):
    """
    车应用详情页
    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 应用封面
        self.detail_app_cover_img = (By.XPATH, App.RESOURCE_ID.format("iv_app_icon"))

        # 应用名
        self.detail_app_name_text = (By.XPATH, App.RESOURCE_ID.format("tv_app_name"))

        # 应用大小
        self.detail_app_size_text = (By.XPATH, App.RESOURCE_ID.format("tv_app_size"))

        # 应用版本号
        self.detail_app_version_text = (By.XPATH, App.RESOURCE_ID.format("tv_app_version"))

        # 应用描述
        self.detail_app_introduce_text = (By.XPATH, App.RESOURCE_ID.format("tv_app_introduce"))

        # 应用下载/打开按钮
        self.detail_app_open_btn = (By.XPATH, App.RESOURCE_ID.format("btn_download_progress"))

        # 右侧应用图片1
        self.detail_app_photo1_img = (By.XPATH, App.RESOURCE_ID.format("iv_app_detail"))

        # 右侧应用图片2
        self.detail_app_photo2_img = (By.XPATH, App.RESOURCE_ID.format("iv_app_detai2"))

    def get_app_cover(self):
        """
        获取应用封面

        :return:
        """
        return self.find_element_o(self.detail_app_cover_img)

    def get_app_name(self):
        """
        获取应用名

        :return:
        """
        return self.find_element_o(self.detail_app_name_text)

    def get_app_size(self):
        """
        获取应用大小

        :return:
        """
        return self.find_element_o(self.detail_app_size_text)

    def get_app_version(self):
        """
        获取应用版本号

        :return:
        """
        return self.find_element_o(self.detail_app_version_text)

    def get_app_introduce(self):
        """
        获取应用描述

        :return:
        """
        return self.find_element_o(self.detail_app_introduce_text)

    def get_app_open(self):
        """
        获取应用打开/下载按钮

        :return:
        """
        return self.find_element_o(self.detail_app_open_btn)

    def get_app_photo1(self):
        """
        获取右侧的应用图片1

        :return:
        """
        return self.find_element_o(self.detail_app_photo1_img)

    def get_app_photo2(self):
        """
        获取右侧的应用图片2

        :return:
        """
        return self.find_element_o(self.detail_app_photo2_img)

    def click_app_open(self):
        """
        点击打开按钮

        :return:
        """
        self.click_element(self.detail_app_open_btn)

    def click_app_photo1(self):
        """
        点击右侧的图片1

        :return:
        """
        self.click_element(self.detail_app_photo1_img)




